// $ANTLR : "Evaluador.g" -> "Evaluador.java"$

	package procesador.consultas;

import antlr.TreeParser;
import antlr.Token;
import antlr.collections.AST;
import antlr.RecognitionException;
import antlr.ANTLRException;
import antlr.NoViableAltException;
import antlr.MismatchedTokenException;
import antlr.SemanticException;
import antlr.collections.impl.BitSet;
import antlr.ASTPair;
import antlr.collections.impl.ASTArray;


public class Evaluador extends antlr.TreeParser       implements EvaluadorTokenTypes
 {
public Evaluador() {
	tokenNames = _tokenNames;
}

	public final void consultas(AST _t) throws RecognitionException {
		
		AST consultas_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST __t2257 = _t;
			AST tmp1_AST_in = (AST)_t;
			match(_t,CONSULTAS);
			_t = _t.getFirstChild();
			{
			_loop2259:
			do {
				if (_t==null) _t=ASTNULL;
				if ((_t.getType()==ASIGN)) {
					consulta(_t);
					_t = _retTree;
				}
				else {
					break _loop2259;
				}
				
			} while (true);
			}
			_t = __t2257;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void consulta(AST _t) throws RecognitionException {
		
		AST consulta_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		AST i = null;
		
		try {      // for error handling
			AST __t2261 = _t;
			AST tmp2_AST_in = (AST)_t;
			match(_t,ASIGN);
			_t = _t.getFirstChild();
			i = (AST)_t;
			match(_t,IDENT);
			_t = _t.getNextSibling();
			query(_t);
			_t = _retTree;
			_t = __t2261;
			_t = _t.getNextSibling();
			if ( inputState.guessing==0 ) {
				/*System.out.println("\tConsulta procesada: " + i.getText());*/
			}
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void query(AST _t) throws RecognitionException {
		
		AST query_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			if (_t==null) _t=ASTNULL;
			switch ( _t.getType()) {
			case SELECT:
			{
				restriccion(_t);
				_t = _retTree;
				break;
			}
			case PROJECT:
			{
				proyeccion(_t);
				_t = _retTree;
				break;
			}
			case UNION:
			{
				union(_t);
				_t = _retTree;
				break;
			}
			case DIFFERENCE:
			{
				diferencia(_t);
				_t = _retTree;
				break;
			}
			case NJOIN:
			{
				concatenacion(_t);
				_t = _retTree;
				break;
			}
			case INTERSECT:
			{
				interseccion(_t);
				_t = _retTree;
				break;
			}
			case PRODUCT:
			{
				producto(_t);
				_t = _retTree;
				break;
			}
			case IDENT:
			{
				AST tmp3_AST_in = (AST)_t;
				match(_t,IDENT);
				_t = _t.getNextSibling();
				break;
			}
			default:
			{
				throw new NoViableAltException(_t);
			}
			}
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void restriccion(AST _t) throws RecognitionException {
		
		AST restriccion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST __t2264 = _t;
			AST tmp4_AST_in = (AST)_t;
			match(_t,SELECT);
			_t = _t.getFirstChild();
			expr_log(_t);
			_t = _retTree;
			query(_t);
			_t = _retTree;
			_t = __t2264;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void proyeccion(AST _t) throws RecognitionException {
		
		AST proyeccion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST __t2266 = _t;
			AST tmp5_AST_in = (AST)_t;
			match(_t,PROJECT);
			_t = _t.getFirstChild();
			campos(_t);
			_t = _retTree;
			query(_t);
			_t = _retTree;
			_t = __t2266;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void union(AST _t) throws RecognitionException {
		
		AST union_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST __t2273 = _t;
			AST tmp6_AST_in = (AST)_t;
			match(_t,UNION);
			_t = _t.getFirstChild();
			query(_t);
			_t = _retTree;
			query(_t);
			_t = _retTree;
			_t = __t2273;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void diferencia(AST _t) throws RecognitionException {
		
		AST diferencia_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST __t2275 = _t;
			AST tmp7_AST_in = (AST)_t;
			match(_t,DIFFERENCE);
			_t = _t.getFirstChild();
			query(_t);
			_t = _retTree;
			query(_t);
			_t = _retTree;
			_t = __t2275;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void concatenacion(AST _t) throws RecognitionException {
		
		AST concatenacion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST __t2277 = _t;
			AST tmp8_AST_in = (AST)_t;
			match(_t,NJOIN);
			_t = _t.getFirstChild();
			query(_t);
			_t = _retTree;
			query(_t);
			_t = _retTree;
			_t = __t2277;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void interseccion(AST _t) throws RecognitionException {
		
		AST interseccion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST __t2279 = _t;
			AST tmp9_AST_in = (AST)_t;
			match(_t,INTERSECT);
			_t = _t.getFirstChild();
			query(_t);
			_t = _retTree;
			query(_t);
			_t = _retTree;
			_t = __t2279;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void producto(AST _t) throws RecognitionException {
		
		AST producto_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST __t2281 = _t;
			AST tmp10_AST_in = (AST)_t;
			match(_t,PRODUCT);
			_t = _t.getFirstChild();
			query(_t);
			_t = _retTree;
			query(_t);
			_t = _retTree;
			_t = __t2281;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void expr_log(AST _t) throws RecognitionException {
		
		AST expr_log_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			if (_t==null) _t=ASTNULL;
			switch ( _t.getType()) {
			case OR:
			{
				AST __t2284 = _t;
				AST tmp11_AST_in = (AST)_t;
				match(_t,OR);
				_t = _t.getFirstChild();
				expr_log(_t);
				_t = _retTree;
				expr_log(_t);
				_t = _retTree;
				_t = __t2284;
				_t = _t.getNextSibling();
				break;
			}
			case AND:
			{
				AST __t2285 = _t;
				AST tmp12_AST_in = (AST)_t;
				match(_t,AND);
				_t = _t.getFirstChild();
				expr_log(_t);
				_t = _retTree;
				expr_log(_t);
				_t = _retTree;
				_t = __t2285;
				_t = _t.getNextSibling();
				break;
			}
			case NOT:
			{
				AST __t2286 = _t;
				AST tmp13_AST_in = (AST)_t;
				match(_t,NOT);
				_t = _t.getFirstChild();
				expr_log(_t);
				_t = _retTree;
				_t = __t2286;
				_t = _t.getNextSibling();
				break;
			}
			case 22:
			{
				AST __t2287 = _t;
				AST tmp14_AST_in = (AST)_t;
				match(_t,22);
				_t = _t.getFirstChild();
				expr_arit(_t);
				_t = _retTree;
				expr_arit(_t);
				_t = _retTree;
				_t = __t2287;
				_t = _t.getNextSibling();
				break;
			}
			case 23:
			{
				AST __t2288 = _t;
				AST tmp15_AST_in = (AST)_t;
				match(_t,23);
				_t = _t.getFirstChild();
				expr_arit(_t);
				_t = _retTree;
				expr_arit(_t);
				_t = _retTree;
				_t = __t2288;
				_t = _t.getNextSibling();
				break;
			}
			case 24:
			{
				AST __t2289 = _t;
				AST tmp16_AST_in = (AST)_t;
				match(_t,24);
				_t = _t.getFirstChild();
				expr_arit(_t);
				_t = _retTree;
				expr_arit(_t);
				_t = _retTree;
				_t = __t2289;
				_t = _t.getNextSibling();
				break;
			}
			case 25:
			{
				AST __t2290 = _t;
				AST tmp17_AST_in = (AST)_t;
				match(_t,25);
				_t = _t.getFirstChild();
				expr_arit(_t);
				_t = _retTree;
				expr_arit(_t);
				_t = _retTree;
				_t = __t2290;
				_t = _t.getNextSibling();
				break;
			}
			case 26:
			{
				AST __t2291 = _t;
				AST tmp18_AST_in = (AST)_t;
				match(_t,26);
				_t = _t.getFirstChild();
				expr_arit(_t);
				_t = _retTree;
				expr_arit(_t);
				_t = _retTree;
				_t = __t2291;
				_t = _t.getNextSibling();
				break;
			}
			case 27:
			{
				AST __t2292 = _t;
				AST tmp19_AST_in = (AST)_t;
				match(_t,27);
				_t = _t.getFirstChild();
				expr_arit(_t);
				_t = _retTree;
				expr_arit(_t);
				_t = _retTree;
				_t = __t2292;
				_t = _t.getNextSibling();
				break;
			}
			default:
			{
				throw new NoViableAltException(_t);
			}
			}
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void campos(AST _t) throws RecognitionException {
		
		AST campos_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST __t2268 = _t;
			AST tmp20_AST_in = (AST)_t;
			match(_t,CAMPOS);
			_t = _t.getFirstChild();
			{
			int _cnt2270=0;
			_loop2270:
			do {
				if (_t==null) _t=ASTNULL;
				if ((_t.getType()==IDENT)) {
					campo(_t);
					_t = _retTree;
				}
				else {
					if ( _cnt2270>=1 ) { break _loop2270; } else {throw new NoViableAltException(_t);}
				}
				
				_cnt2270++;
			} while (true);
			}
			_t = __t2268;
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void campo(AST _t) throws RecognitionException {
		
		AST campo_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			AST tmp21_AST_in = (AST)_t;
			match(_t,IDENT);
			_t = _t.getNextSibling();
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void expresion(AST _t) throws RecognitionException {
		
		AST expresion_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			if (_t==null) _t=ASTNULL;
			switch ( _t.getType()) {
			case OR:
			case AND:
			case NOT:
			case 22:
			case 23:
			case 24:
			case 25:
			case 26:
			case 27:
			{
				expr_log(_t);
				_t = _retTree;
				break;
			}
			case IDENT:
			case 28:
			case 29:
			case 30:
			case 31:
			case NUMERO:
			case CADENA:
			{
				expr_arit(_t);
				_t = _retTree;
				break;
			}
			default:
			{
				throw new NoViableAltException(_t);
			}
			}
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	public final void expr_arit(AST _t) throws RecognitionException {
		
		AST expr_arit_AST_in = (_t == ASTNULL) ? null : (AST)_t;
		
		try {      // for error handling
			if (_t==null) _t=ASTNULL;
			switch ( _t.getType()) {
			case 28:
			{
				AST __t2294 = _t;
				AST tmp22_AST_in = (AST)_t;
				match(_t,28);
				_t = _t.getFirstChild();
				expr_arit(_t);
				_t = _retTree;
				expr_arit(_t);
				_t = _retTree;
				_t = __t2294;
				_t = _t.getNextSibling();
				break;
			}
			case 30:
			{
				AST __t2300 = _t;
				AST tmp23_AST_in = (AST)_t;
				match(_t,30);
				_t = _t.getFirstChild();
				expr_arit(_t);
				_t = _retTree;
				expr_arit(_t);
				_t = _retTree;
				_t = __t2300;
				_t = _t.getNextSibling();
				break;
			}
			case 31:
			{
				AST __t2301 = _t;
				AST tmp24_AST_in = (AST)_t;
				match(_t,31);
				_t = _t.getFirstChild();
				expr_arit(_t);
				_t = _retTree;
				expr_arit(_t);
				_t = _retTree;
				_t = __t2301;
				_t = _t.getNextSibling();
				break;
			}
			case IDENT:
			{
				AST tmp25_AST_in = (AST)_t;
				match(_t,IDENT);
				_t = _t.getNextSibling();
				break;
			}
			case NUMERO:
			{
				AST tmp26_AST_in = (AST)_t;
				match(_t,NUMERO);
				_t = _t.getNextSibling();
				break;
			}
			case CADENA:
			{
				AST tmp27_AST_in = (AST)_t;
				match(_t,CADENA);
				_t = _t.getNextSibling();
				break;
			}
			default:
				boolean synPredMatched2297 = false;
				if (_t==null) _t=ASTNULL;
				if (((_t.getType()==29))) {
					AST __t2297 = _t;
					synPredMatched2297 = true;
					inputState.guessing++;
					try {
						{
						AST __t2296 = _t;
						AST tmp28_AST_in = (AST)_t;
						match(_t,29);
						_t = _t.getFirstChild();
						expr_arit(_t);
						_t = _retTree;
						expr_arit(_t);
						_t = _retTree;
						_t = __t2296;
						_t = _t.getNextSibling();
						}
					}
					catch (RecognitionException pe) {
						synPredMatched2297 = false;
					}
					_t = __t2297;
inputState.guessing--;
				}
				if ( synPredMatched2297 ) {
					AST __t2298 = _t;
					AST tmp29_AST_in = (AST)_t;
					match(_t,29);
					_t = _t.getFirstChild();
					expr_arit(_t);
					_t = _retTree;
					expr_arit(_t);
					_t = _retTree;
					_t = __t2298;
					_t = _t.getNextSibling();
				}
				else if ((_t.getType()==29)) {
					AST __t2299 = _t;
					AST tmp30_AST_in = (AST)_t;
					match(_t,29);
					_t = _t.getFirstChild();
					expr_arit(_t);
					_t = _retTree;
					_t = __t2299;
					_t = _t.getNextSibling();
				}
			else {
				throw new NoViableAltException(_t);
			}
			}
		}
		catch (RecognitionException ex) {
			if (inputState.guessing==0) {
				reportError(ex);
				if (_t!=null) {_t = _t.getNextSibling();}
			} else {
			  throw ex;
			}
		}
		_retTree = _t;
	}
	
	
	public static final String[] _tokenNames = {
		"<0>",
		"EOF",
		"<2>",
		"NULL_TREE_LOOKAHEAD",
		"CONSULTAS",
		"CAMPOS",
		"IDENT",
		"ASIGN",
		"\";\"",
		"UNION",
		"DIFFERENCE",
		"NJOIN",
		"INTERSECT",
		"PRODUCT",
		"\"(\"",
		"\")\"",
		"SELECT",
		"PROJECT",
		"\",\"",
		"OR",
		"AND",
		"NOT",
		"\"<\"",
		"\"<=\"",
		"\">\"",
		"\">=\"",
		"\"<>\"",
		"\"=\"",
		"\"+\"",
		"\"-\"",
		"\"*\"",
		"\"/\"",
		"NUMERO",
		"CADENA"
	};
	
	}
	
